import java.util.Scanner;

public class Test19 {
    static int m,n;
    static int ret;
    static int[] dx = {0,1};
    static int[] dy = {1,0};
    static boolean[][] vis;

    public static int wardrobeFinishing(int _m, int _n, int cnt) {
        //初始化
        m = _m;
        n = _n;
        vis = new boolean[m][n];
        dfs(0,0,cnt);
        return ret;
    }

    static void dfs(int i,int j,int cnt){
        ret++;
        vis[i][j] = true;
        for(int k = 0;k < dx.length;k++){
            int x = dx[k] + i, y = dy[k] + j;
            if(x >= 0 && x < m && y >= 0 && y < n && !vis[x][y] && check(x,y,cnt)){
                dfs(x,y,cnt);
            }
        }
    }

    static boolean check(int i,int j,int cnt){
        int tmp = 0;
        while(i != 0){
            tmp += i % 10;
            i /= 10;
        }
        while(j != 0){
            tmp += j % 10;
            j /= 10;
        }
        return tmp <= cnt;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = 4, n = 7, cnt = 5;
        wardrobeFinishing(m,n,cnt);
        System.out.println(ret);
    }
}
